#include<stdio.h>

#include<string.h>

char a[6000000];
int main() {
	int flog = 1, key, j,c,i=0;;
	int m = 0;
	while (1) {
		int b[60000][4] = { 0 };
		while ((c=getchar())!='\n')
		{
			a[i++] = c;
		}
		a[i] = 0;
		flog = 1; key = 0; m = 0;
		if (strcmp(a, "exit") == 0) {
			printf("End Of Input\n");
			return 0;
		}
		for (int i = 0; i<strlen(a); i++) {
			if ((a[i]>122 || a[i]<65 || a[i]>90 && a[i]<97) && a[i] != ' ') {
				printf("Input Error\n");
				flog = 0;
				break;
			}
			if (flog) {

				if (a[i] != ' ') {
					b[m][1]++;
				}
				else {
					if (a[i - 1] != ' ') {
						b[m][3] = i - 1;
					}
					if (a[i] == ' '&&a[i + 1 != ' ']) {
						if (b[m][1]>key)
							key = b[m][1];
						m++;
						b[m][2] = i + 1;
					}
				}
			}
		}
		if (flog) {
			b[m][3] = strlen(a) - 1;
			if (b[m][1]>key) {
				key = b[m][1];
			}
			for (int i = 0; i <= m; i++) {
				if (b[i][1] == key) {
					for (j = b[i][2]; j <= b[i][3]; j++) {
						printf("%c", a[j]);
					}
					printf(",");
				}
			}
			printf("\n");
		}
	}
	return 0;
}